From 7354b67f3f2cb0621a9a0d225c4ee2dae15655af Mon Sep 17 00:00:00 2001 From: robertlipe Date: Mon, 24 Feb 2014 07:03:06 +0000 Subject: [PATCH] Vacuum up more crumbs of the NEW_STRING paths for cases that are "obviously" correct. The ones that remain really are essentially TODO/FIXME for otherwise problematic code. git-svn-id: http://gpsbabel.googlecode.com/svn/trunk@4760 f51c46e8-681c-474f-0cfe-069cfd0219fb --- gpsbabel/defs.h | 37 ++++++++++++---------------- gpsbabel/dmtlog.cc | 4 ---- gpsbabel/easygps.cc | 12 ---------- gpsbabel/garmin.cc | 31 ------------------------ gpsbabel/garmin_device_xml.cc | 12 ---------- gpsbabel/garmin_gpi.cc | 45 ----------------------------------- gpsbabel/garmin_txt.cc | 24 ------------------- gpsbabel/gbfile.h | 3 --- gpsbabel/googledir.cc | 17 ++++--------- gpsbabel/gpx.cc | 1 - gpsbabel/igc.cc | 32 ------------------------- gpsbabel/ignrando.cc | 8 ------- gpsbabel/ik3d.cc | 4 ---- gpsbabel/interpolate.cc | 21 +--------------- gpsbabel/lowranceusr4.cc | 4 ---- gpsbabel/maggeo.cc | 4 ---- gpsbabel/mapsource.cc | 8 ------- gpsbabel/mkshort.cc | 14 +---------- gpsbabel/mmo.cc | 2 +- gpsbabel/naviguide.cc | 2 +- gpsbabel/netstumbler.cc | 4 ---- gpsbabel/nmea.cc | 7 +----- gpsbabel/raymarine.cc | 8 ------- gpsbabel/stmsdf.cc | 4 ---- gpsbabel/stmwpp.cc | 6 +---- gpsbabel/tef_xml.cc | 4 ---- gpsbabel/tmpro.cc | 21 ---------------- gpsbabel/tpg.cc | 9 ------- gpsbabel/unicsv.cc | 13 ---------- gpsbabel/vitosmt.cc | 5 ---- gpsbabel/waypt.cc | 13 ---------- gpsbabel/wfff_xml.cc | 1 - gpsbabel/xmlgeneric.cc | 8 ------- gpsbabel/xol.cc | 4 ---- 34 files changed, 26 insertions(+), 366 deletions(-) diff --git a/gpsbabel/defs.h b/gpsbabel/defs.h index 8e9182709..a71535a56 100644 --- a/gpsbabel/defs.h +++ b/gpsbabel/defs.h @@ -43,8 +43,6 @@ # include "src/core/datetime.h" #define CSTR(qstr) (qstr.toUtf8().constData()) -#define CSTRE_(qstr, enc) (enc->fromUnicode(qstr).constData()) -#define CSTRE(qstr) (CSTRE_(qstr, codec)) /* * Amazingly, this constant is not specified in the standard... @@ -431,22 +429,20 @@ const global_trait* get_traits(); #define WAYPT_GET(wpt,member,def) ((wpt->wpt_flags.member) ? (wpt->member) : (def)) #define WAYPT_UNSET(wpt,member) wpt->wpt_flags.member = 0 #define WAYPT_HAS(wpt,member) (wpt->wpt_flags.member) + +#define CSTRc(qstr) (qstr.toLatin1().constData()) +// Maybe the XmlGeneric string callback really shouldn't have a type +// of its own; this was a crutch during the move from char* to QString. +// It's "just" a search and replace to make it go away, but it might +// be convenient to overload some day. +typedef const QString& xg_string; + /* * This is a waypoint, as stored in the GPSR. It tries to not * cater to any specific model or protocol. Anything that needs to * be truncated, edited, or otherwise trimmed should be done on the * way to the target. */ -#if NEW_STRINGS - typedef QString String; - #define CSTRc(qstr) (qstr.toLatin1().constData()) - typedef const QString& xg_string; -#else - #define CSTRc(qstr) (qstr) - typedef char* String; - typedef const char* xg_string; -#endif - class Waypoint { private: @@ -480,20 +476,20 @@ public: * minimum length for shortname is 6 characters for NMEA units, * 8 for Magellan and 10 for Vista. These are only guidelines. */ - String shortname; + QString shortname; /* * description is typically a human readable description of the * waypoint. It may be used as a comment field in some receivers. * These are probably under 40 bytes, but that's only a guideline. */ - String description; + QString description; /* * notes are relatively long - over 100 characters - prose associated * with the above. Unlike shortname and description, these are never * used to compute anything else and are strictly "passed through". * Few formats support this. */ - String notes; + QString notes; /* TODO: UrlLink should probably move to a "real" class of its own. */ @@ -563,8 +559,8 @@ class route_head public: queue Q; /* Link onto parent list. */ queue waypoint_list; /* List of child waypoints */ - String rte_name; - String rte_desc; + QString rte_name; + QString rte_desc; QString rte_url; int rte_num; int rte_waypt_ct; /* # waypoints in waypoint list */ @@ -741,7 +737,7 @@ short_handle MKSHORT_NEW_HANDLE(DEBUG_PARAMS); #define mkshort( a, b) MKSHORT(a,b,__FILE__, __LINE__) #define mkshort_new_handle() MKSHORT_NEW_HANDLE(__FILE__,__LINE__) #endif -String mkshort_from_wpt(short_handle h, const Waypoint* wpt); +QString mkshort_from_wpt(short_handle h, const Waypoint* wpt); void mkshort_del_handle(short_handle* h); void setshort_length(short_handle, int n); void setshort_badchars(short_handle, const char*); @@ -898,9 +894,6 @@ void* xcalloc(size_t nmemb, size_t size); void* xmalloc(size_t size); void* xrealloc(void* p, size_t s); void xfree(const void* mem); -#ifndef NEW_STRINGS -char* xstrdup(const char* s); -#endif char* xstrdup(const QString& s); char* xstrndup(const char* s, size_t n); char* xstrndupt(const char* s, size_t n); @@ -964,7 +957,7 @@ const char* xstrrstr(const char* s1, const char* s2); void rtrim(char* s); char* lrtrim(char* s); int xasprintf(char** strp, const char* fmt, ...) PRINTFLIKE(2, 3); -int xasprintf(String* strp, const char* fmt, ...) PRINTFLIKE(2, 3); +int xasprintf(QString* strp, const char* fmt, ...) PRINTFLIKE(2, 3); int xvasprintf(char** strp, const char* fmt, va_list ap); char* strupper(char* src); char* strlower(char* src); diff --git a/gpsbabel/dmtlog.cc b/gpsbabel/dmtlog.cc index 0adad2eaf..88bfd3f3e 100644 --- a/gpsbabel/dmtlog.cc +++ b/gpsbabel/dmtlog.cc @@ -150,11 +150,7 @@ finalize_pt(Waypoint* wpt) static void tlog3a_xgcb_version(xg_string args, const QXmlStreamAttributes*) { -#if NEW_STRINGS if (args != "1") { -#else - if (strcmp(args, "1") != 0) { -#endif fatal(MYNAME ": Unsupported file version '%s'!\n", CSTRc(args)); } } diff --git a/gpsbabel/easygps.cc b/gpsbabel/easygps.cc index b5986c379..49ecea6c6 100644 --- a/gpsbabel/easygps.cc +++ b/gpsbabel/easygps.cc @@ -156,19 +156,11 @@ static void ez_disp(const Waypoint* wpt) { gbfputc('W', file_out); -#if NEW_STRINGS if (!wpt->shortname.isEmpty()) { -#else - if (wpt->shortname) { -#endif gbfputc(1, file_out); gbfputpstr(wpt->shortname, file_out); } -#if NEW_STRINGS if (!wpt->description.isEmpty()) { -#else - if (wpt->description) { -#endif gbfputc(3, file_out); gbfputpstr(wpt->description, file_out); } @@ -181,11 +173,7 @@ ez_disp(const Waypoint* wpt) gbfputc(0x64, file_out); gbfputdbl(wpt->longitude, file_out); -#if NEW_STRINGS if (!wpt->notes.isEmpty()) { -#else - if (wpt->notes) { -#endif gbfputc(5, file_out); gbfputpstr(wpt->notes, file_out); } diff --git a/gpsbabel/garmin.cc b/gpsbabel/garmin.cc index 5d1a9d6cd..704c75c36 100644 --- a/gpsbabel/garmin.cc +++ b/gpsbabel/garmin.cc @@ -911,7 +911,6 @@ waypoint_prepare(void) char* ident; char obuf[256]; -#if NEW_STRINGS QString src; if (!wpt->description.isEmpty()) { src = wpt->description; @@ -919,15 +918,6 @@ waypoint_prepare(void) if (!wpt->notes.isEmpty()) { src = wpt->notes; } -#else - char *src = NULL; - if (wpt->description) { - src = wpt->description; - } - if (wpt->notes) { - src = wpt->notes; - } -#endif /* * mkshort will do collision detection and namespace @@ -949,11 +939,7 @@ waypoint_prepare(void) // If we were explictly given a comment from GPX, use that. // This logic really is horrible and needs to be untangled. -#if NEW_STRINGS if (!wpt->description.isEmpty() && -#else - if (wpt->description && -#endif global_opts.smart_names && !wpt->gc_data->diff) { memcpy(tx_waylist[i]->cmnt, CSTRc(wpt->description), strlen(CSTRc(wpt->description))); } else { @@ -1045,11 +1031,7 @@ route_hdr_pr(const route_head* rte) { (*cur_tx_routelist_entry)->rte_num = rte->rte_num; (*cur_tx_routelist_entry)->isrte = 1; -#if NEW_STRINGS if (!rte->rte_name.isEmpty()) { -#else - if (rte->rte_name) { -#endif strncpy((*cur_tx_routelist_entry)->rte_ident, CSTRc(rte->rte_name), sizeof((*cur_tx_routelist_entry)->rte_ident)); } @@ -1092,13 +1074,8 @@ route_waypt_pr(const Waypoint* wpt) // This was strncpy(rte->ident, wpt->shortname, sizeof(rte->ident)); char* d; d = rte->ident; -#if NEW_STRINGS for (int idx = 0; idx < wpt->shortname.length(); idx++) { int c = wpt->shortname[idx].toLatin1(); -#else - for (char* s = wpt->shortname; *s; s++) { - int c = *s; -#endif if (receiver_must_upper && isalpha(c)) { c = toupper(c); } @@ -1151,11 +1128,7 @@ static void track_hdr_pr(const route_head* trk_head) { (*cur_tx_tracklist_entry)->ishdr = gpsTrue; -#if NEW_STRINGS if (!trk_head->rte_name.isEmpty()) { -#else - if (trk_head->rte_name) { -#endif strncpy((*cur_tx_tracklist_entry)->trk_ident, CSTRc(trk_head->rte_name), sizeof((*cur_tx_tracklist_entry)->trk_ident)); (*cur_tx_tracklist_entry)->trk_ident[sizeof((*cur_tx_tracklist_entry)->trk_ident)-1] = 0; } else { @@ -1172,11 +1145,7 @@ track_waypt_pr(const Waypoint* wpt) (*cur_tx_tracklist_entry)->lon = wpt->longitude; (*cur_tx_tracklist_entry)->alt = (wpt->altitude != unknown_alt) ? wpt->altitude : 1e25; (*cur_tx_tracklist_entry)->Time = wpt->GetCreationTime().toTime_t();; -#if NEW_STRINGS if (!wpt->shortname.isEmpty()) { -#else - if (wpt->shortname) { -#endif strncpy((*cur_tx_tracklist_entry)->trk_ident, CSTRc(wpt->shortname), sizeof((*cur_tx_tracklist_entry)->trk_ident)); (*cur_tx_tracklist_entry)->trk_ident[sizeof((*cur_tx_tracklist_entry)->trk_ident)-1] = 0; } diff --git a/gpsbabel/garmin_device_xml.cc b/gpsbabel/garmin_device_xml.cc index cc4735afb..3157ba7fc 100644 --- a/gpsbabel/garmin_device_xml.cc +++ b/gpsbabel/garmin_device_xml.cc @@ -40,11 +40,7 @@ jmp_buf gdx_jmp_buf; void type_s(xg_string args, const QXmlStreamAttributes*) { -#if NEW_STRINGS type = args.compare("GPSData"); -#else - type = strcmp(args, "GPSData"); -#endif } void device_s(xg_string args, const QXmlStreamAttributes*) @@ -81,11 +77,7 @@ void dir_s(xg_string args, const QXmlStreamAttributes*) if (type) { return; } -#if NEW_STRINGS if ((args == "OutputFromUnit")) { -#else - if (0 == strcmp(args, "OutputFromUnit")) { -#endif xasprintf(&my_gdx_info->from_device.path, "%s%c%s", mountpoint, GB_PATHSEP, path); my_gdx_info->from_device.basename = xstrdup(base); @@ -94,11 +86,7 @@ void dir_s(xg_string args, const QXmlStreamAttributes*) my_gdx_info->from_device.path, my_gdx_info->from_device.basename, my_gdx_info->from_device.extension); -#if NEW_STRINGS } if ((args == "InputToUnit")) { -#else - } else if (0 == strcmp(args, "InputToUnit")) { -#endif xasprintf(&my_gdx_info->to_device.path, "%s%c%s", mountpoint, GB_PATHSEP, path); my_gdx_info->to_device.basename = xstrdup(base); diff --git a/gpsbabel/garmin_gpi.cc b/gpsbabel/garmin_gpi.cc index 62c0e400e..51a3f2a14 100644 --- a/gpsbabel/garmin_gpi.cc +++ b/gpsbabel/garmin_gpi.cc @@ -396,11 +396,7 @@ read_poi(const int sz, const int tag) (void) gbfgetint16(fin); /* ? always 1 ? */ (void) gbfgetc(fin); /* seems to 1 when extra options present */ -#if NEW_STRINGS - wpt->shortname = gpi_read_string("Shortname"); -#else wpt->shortname = gpi_read_string("Shortname"); -#endif while (gbftell(fin) < (gbsize_t)(pos + sz - 4)) { int tag = gbfgetint32(fin); @@ -589,18 +585,10 @@ read_tag(const char* caller, const int tag, Waypoint* wpt) break; } -#if NEW_STRINGS if (!wpt->description.isEmpty()) { -#else - if (wpt->description) { -#endif wpt->notes = str; } else { -#if NEW_STRINGS wpt->description = str; -#else - wpt->description = str; -#endif } break; @@ -752,11 +740,7 @@ compare_wpt_cb(const queue* a, const queue* b) { const Waypoint* wa = (Waypoint*) a; const Waypoint* wb = (Waypoint*) b; -#if NEW_STRINGS return wa->shortname.compare(wb->shortname); -#else - return strcmp(wa->shortname, wb->shortname); -#endif } static char @@ -765,25 +749,6 @@ compare_strings(const QString& s1, const QString& s2) return s1.compare(s2); } -#if !NEW_STRINGS -static char -compare_strings(const char* s1, const char* s2) -{ - if (s1 == s2) { - return 0; - } else if (s1) { - if (s2) { - return strcmp(s1, s2); - } else { - return 1; - } - } else { - return 1; - } -} -#endif - - static writer_data_t* wdata_alloc() { @@ -927,11 +892,7 @@ wdata_compute_size(writer_data_t* data) res += 12; /* tag/sz/sub-sz */ res += 19; /* poi fixed size */ -#if NEW_STRINGS res += wpt->shortname.length(); -#else - res += strlen(wpt->shortname); -#endif if (! opt_hide_bitmap) { res += 10; /* tag(4) */ } @@ -1291,13 +1252,7 @@ enum_waypt_cb(const Waypoint* ref) wpt = new Waypoint(*ref); if (*opt_unique == '1') { -#if NEW_STRINGS wpt->shortname = mkshort(short_h, wpt->shortname); -#else - char* str = mkshort(short_h, wpt->shortname); - xfree(wpt->shortname); - wpt->shortname = str; -#endif } wdata_add_wpt(wdata, wpt); diff --git a/gpsbabel/garmin_txt.cc b/gpsbabel/garmin_txt.cc index 0e624c7e4..ff67ed335 100644 --- a/gpsbabel/garmin_txt.cc +++ b/gpsbabel/garmin_txt.cc @@ -226,11 +226,7 @@ sort_waypt_cb(const void* a, const void* b) { const Waypoint* wa = *(Waypoint**)a; const Waypoint* wb = *(Waypoint**)b; -#if NEW_STRINGS return wa->shortname.compare(wb->shortname, Qt::CaseInsensitive); -#else - return case_ignore_strcmp(QString::fromLatin1(wa->shortname), QString::fromLatin1(wb->shortname)); -#endif } @@ -354,11 +350,7 @@ print_position(const Waypoint* wpt) if (! valid) { gbfprintf(fout, "#####\n"); fatal(MYNAME ": %s (%s) is outside of convertable area \"%s\"!\n", -#if NEW_STRINGS wpt->shortname.isEmpty() ? "Waypoint" : CSTR(wpt->shortname), -#else - wpt->shortname ? CSTRc(wpt->shortname) : "Waypoint", -#endif pretty_deg_format(wpt->latitude, wpt->longitude, 'd', NULL, 0), gt_get_mps_grid_longname(grid_index, MYNAME)); } @@ -566,19 +558,11 @@ write_waypt(const Waypoint* wpt) wpt_type = gt_waypt_class_names[0]; } -#if NEW_STRINGS gbfprintf(fout, "Waypoint\t%s\t", CSTRc(wpt->shortname)); -#else - gbfprintf(fout, "Waypoint\t%s\t", (wpt->shortname) ? CSTRc(wpt->shortname) : ""); -#endif if (wpt_class <= gt_waypt_class_airport_ndb) { QString temp = wpt->notes; if (temp.isEmpty()) { -#if NEW_STRINGS if (wpt->description != wpt->shortname) { -#else - if (wpt->description && (strcmp(wpt->description, wpt->shortname) != 0)) { -#endif temp = wpt->description; } else { temp = ""; @@ -660,11 +644,7 @@ route_disp_hdr_cb(const route_head* rte) gtxt_flags.route_header_written = 1; gbfprintf(fout, "\r\n\r\nHeader\t%s\r\n", headers[route_header]); } -#if NEW_STRINGS print_string("\r\nRoute\t%s\t", current_trk->rte_name); -#else - print_string("\r\nRoute\t%s\t", current_trk->rte_name ? CSTRc(current_trk->rte_name) : ""); -#endif print_distance(cur_info->length, 0, 1, 0); print_course(cur_info->first_wpt, cur_info->last_wpt); gbfprintf(fout, "\t%d waypoints\t", cur_info->count); @@ -716,11 +696,7 @@ track_disp_hdr_cb(const route_head* track) gtxt_flags.track_header_written = 1; gbfprintf(fout, "\r\n\r\nHeader\t%s\r\n", headers[track_header]); } -#if NEW_STRINGS print_string("\r\nTrack\t%s\t", current_trk->rte_name); -#else - print_string("\r\nTrack\t%s\t", current_trk->rte_name ? CSTRc(current_trk->rte_name) : ""); -#endif print_date_and_time(cur_info->start, 0); print_date_and_time(cur_info->time, 1); print_distance(cur_info->length, 0, 1, 0); diff --git a/gpsbabel/gbfile.h b/gpsbabel/gbfile.h index 669dd2073..7cf0c726a 100644 --- a/gpsbabel/gbfile.h +++ b/gpsbabel/gbfile.h @@ -102,9 +102,6 @@ int gbfprintf(gbfile* file, const char* format, ...); int gbfputc(int c, gbfile* file); int gbfputs(const char* s, gbfile* file); int gbfputs(const QString& s, gbfile* file); -#if NEW_STRINGS -typedef QString String; -#endif int gbfwrite(const void* buf, const gbsize_t size, const gbsize_t members, gbfile* file); int gbfflush(gbfile* file); diff --git a/gpsbabel/googledir.cc b/gpsbabel/googledir.cc index 8f591774c..90b2d6171 100644 --- a/gpsbabel/googledir.cc +++ b/gpsbabel/googledir.cc @@ -35,7 +35,6 @@ static QString instructions; static short_handle desc_handle; #define MYNAME "googledir" -#define MY_CBUF 4096 static xg_callback goog_points, goog_poly_e; static xg_callback goog_instr; @@ -68,16 +67,16 @@ static long decode_goog64(const QByteArray& str, int& pos) { long result = 0; - unsigned char c = 0; unsigned char shift = 0; if (pos >= str.size()) { return 0; } + unsigned char c; do { - c = (unsigned char)str.at(pos++)-'?'; - result |= (c & 31)<rte_name = "overview"; routehead->rte_desc = "Overview"; } else { @@ -110,10 +105,8 @@ goog_poly_e(xg_string args, const QXmlStreamAttributes*) } else { utf_string utf; utf.is_html = 1; - utf.utfstring = /*QString::fromUtf8*/(instructions); - char *s = strip_html(&utf); - routehead->rte_desc = s; - xfree(s); + utf.utfstring = instructions; + routehead->rte_desc = strip_html(&utf); instructions = QString(); } } diff --git a/gpsbabel/gpx.cc b/gpsbabel/gpx.cc index a6c830cdd..cc16df9c0 100644 --- a/gpsbabel/gpx.cc +++ b/gpsbabel/gpx.cc @@ -73,7 +73,6 @@ static format_specific_data** fs_ptr; #define MYNAME "GPX" -#define MY_CBUF_SZ 4096 #ifndef CREATOR_NAME_URL # define CREATOR_NAME_URL "GPSBabel - http://www.gpsbabel.org" #endif diff --git a/gpsbabel/igc.cc b/gpsbabel/igc.cc index 23109165b..c1feb527b 100644 --- a/gpsbabel/igc.cc +++ b/gpsbabel/igc.cc @@ -464,22 +464,14 @@ static void data_read(void) static void detect_pres_track(const route_head* rh) { -#if NEW_STRINGS if (rh->rte_name.startsWith(PRESTRKNAME)) { -#else - if (rh->rte_name && strncmp(rh->rte_name, PRESTRKNAME, 6) == 0) { -#endif head = rh; } } static void detect_gnss_track(const route_head* rh) { -#if NEW_STRINGS if (rh->rte_name.startsWith(GNSSTRKNAME)) { -#else - if (rh->rte_name && strncmp(rh->rte_name, GNSSTRKNAME, 6) == 0) { -#endif head = rh; } } @@ -493,15 +485,9 @@ static void detect_other_track(const route_head* rh) } // Find other track with the most waypoints if (rh->rte_waypt_ct > max_waypt_ct && -#if NEW_STRINGS (rh->rte_name.isEmpty() || (!rh->rte_name.startsWith(PRESTRKNAME) && !rh->rte_name.startsWith(GNSSTRKNAME)))) { -#else - (!rh->rte_name || - (strncmp(rh->rte_name, PRESTRKNAME, 6) != 0 && - strncmp(rh->rte_name, GNSSTRKNAME, 6) != 0))) { -#endif head = rh; max_waypt_ct = rh->rte_waypt_ct; } @@ -650,11 +636,7 @@ static void wr_header(void) static void wr_task_wpt_name(const Waypoint* wpt, const char* alt_name) { gbfprintf(file_out, "C%s%s\r\n", latlon2str(wpt), -#if NEW_STRINGS !wpt->description.isEmpty() ? CSTR(wpt->description) : !wpt->shortname.isEmpty() ? CSTR(wpt->shortname) : alt_name); -#else - wpt->description ? wpt->description : wpt->shortname ? wpt->shortname : alt_name); -#endif } static void wr_task_hdr(const route_head* rte) @@ -674,19 +656,11 @@ static void wr_task_hdr(const route_head* rte) // See if the takeoff and landing waypoints are there or if we need to // generate them. wpt = (Waypoint*) QUEUE_LAST(&rte->waypoint_list); -#if NEW_STRINGS if (wpt->shortname.startsWith("LANDING")) { -#else - if (wpt->shortname && strncmp(wpt->shortname, "LANDING", 6) == 0) { -#endif num_tps--; } wpt = (Waypoint*) QUEUE_FIRST(&rte->waypoint_list); -#if NEW_STRINGS if (wpt->shortname.startsWith("TAKEOFF")) { -#else - if (wpt->shortname && strncmp(wpt->shortname, "TAKEOFF", 6) == 0) { -#endif have_takeoff = 1; num_tps--; } @@ -701,16 +675,10 @@ static void wr_task_hdr(const route_head* rte) fatal(MYNAME ": Bad task route timestamp\n"); } -#if NEW_STRINGS if (!rte->rte_desc.isEmpty()) { // desc will be something like "IGCDATE160701: 500KTri" sscanf(CSTR(rte->rte_desc), DATEMAGIC "%6[0-9]: %s", flight_date, task_desc); } -#else - if (rte->rte_desc) { - sscanf(rte->rte_desc, DATEMAGIC "%6[0-9]: %s", flight_date, task_desc); - } -#endif gbfprintf(file_out, "C%s%s%s%04u%02u%s\r\n", date2str(tm), tod2str(tm), flight_date, task_num++, num_tps, task_desc); diff --git a/gpsbabel/ignrando.cc b/gpsbabel/ignrando.cc index 0efd0f3d5..bd04cceb7 100644 --- a/gpsbabel/ignrando.cc +++ b/gpsbabel/ignrando.cc @@ -92,11 +92,7 @@ ignr_start(xg_string args, const QXmlStreamAttributes* attrv) static void ignr_nb_etapes(xg_string args, const QXmlStreamAttributes* attrv) { -#if NEW_STRINGS xmlpoints = args.toInt(); -#else - xmlpoints = atoi(args); -#endif } static void @@ -126,11 +122,7 @@ ignr_etape_end(xg_string args, const QXmlStreamAttributes* attrv) static void ignr_etape_pos(xg_string args, const QXmlStreamAttributes* attrv) { -#if NEW_STRINGS ignr_xml_error((wpt == NULL) || (args.isEmpty())); -#else - ignr_xml_error((wpt == NULL) || (args == NULL)); -#endif if (2 != sscanf(CSTRc(args), "%lf,%lf", &wpt->latitude, &wpt->longitude)) { fatal(MYNAME ": Invalid coordinates \"%s\"!\n", CSTRc(args)); diff --git a/gpsbabel/ik3d.cc b/gpsbabel/ik3d.cc index a17e74be9..382184ae6 100644 --- a/gpsbabel/ik3d.cc +++ b/gpsbabel/ik3d.cc @@ -107,11 +107,7 @@ static void iktobj_type(xg_string args, const QXmlStreamAttributes*) { ikt_object_end(); -#if NEW_STRINGS switch (args.toInt()) { -#else - switch (atoi(args)) { -#endif case 0: waypt = new Waypoint; break; diff --git a/gpsbabel/interpolate.cc b/gpsbabel/interpolate.cc index 975c34472..50f26595e 100644 --- a/gpsbabel/interpolate.cc +++ b/gpsbabel/interpolate.cc @@ -99,18 +99,9 @@ interpfilt_process(void) timen += interval) { Waypoint* wpt_new = new Waypoint(*wpt); wpt_new->SetCreationTime(timen); -#if NEW_STRINGS wpt_new->shortname = QString(); wpt_new->description = QString(); -#else - if (wpt_new->shortname) { - xfree(wpt_new->shortname); - } - if (wpt_new->description) { - xfree(wpt_new->description); - } - wpt_new->shortname = wpt_new->description = NULL; -#endif + linepart(lat1, lon1, wpt->latitude, wpt->longitude, (double)(timen-time1)/ @@ -137,18 +128,8 @@ interpfilt_process(void) Waypoint* wpt_new = new Waypoint(*wpt); wpt_new->SetCreationTime(distn/curdist* (wpt->creation_time.toTime_t() - time1) + time1); -#if NEW_STRINGS wpt_new->shortname = QString(); wpt_new->description = QString(); -#else - if (wpt_new->shortname) { - xfree(wpt_new->shortname); - } - if (wpt_new->description) { - xfree(wpt_new->description); - } - wpt_new->shortname = wpt_new->description = NULL; -#endif linepart(lat1, lon1, wpt->latitude, wpt->longitude, distn/curdist, diff --git a/gpsbabel/lowranceusr4.cc b/gpsbabel/lowranceusr4.cc index 94d72ba61..0116773f8 100644 --- a/gpsbabel/lowranceusr4.cc +++ b/gpsbabel/lowranceusr4.cc @@ -289,11 +289,7 @@ static char same_points(const Waypoint* A, const Waypoint* B) { return ( /* !!! We are case-sensitive !!! */ -#if NEW_STRINGS (A->shortname == B->shortname) && -#else - (strcmp(A->shortname, B->shortname) == 0) && -#endif (A->latitude == B->latitude) && (A->longitude == B->longitude)); } diff --git a/gpsbabel/maggeo.cc b/gpsbabel/maggeo.cc index f31340463..1d4972516 100644 --- a/gpsbabel/maggeo.cc +++ b/gpsbabel/maggeo.cc @@ -272,11 +272,7 @@ maggeo_waypt_pr(const Waypoint* waypointp) QString placeddate = maggeo_fmtdate(waypointp->creation_time); QString lfounddate = maggeo_fmtdate(waypointp->gc_data->last_found); QString cname = mkshort(desc_handle, -#if NEW_STRINGS waypointp->notes.isEmpty() ? waypointp->description : waypointp->notes); -#else - QString(waypointp->notes ? waypointp->notes : waypointp->description)); -#endif placer = waypointp->gc_data->placer; /* diff --git a/gpsbabel/mapsource.cc b/gpsbabel/mapsource.cc index f052790cb..3a044483a 100644 --- a/gpsbabel/mapsource.cc +++ b/gpsbabel/mapsource.cc @@ -663,11 +663,7 @@ mps_waypoint_w(gbfile* mps_file, int mps_ver, const Waypoint* wpt, const int isR + NULL (1) + prox(9) + display(4) + colour(4) + symbol(4) + city(sz) + state(sz) + facility(sz) + unknown2(1) + depth(9) + unknown3(7) */ /* -1 as reclen is interpreted from zero meaning a reclength of one */ -#if NEW_STRINGS if (!wpt->notes.isEmpty()) { -#else - if (wpt->notes) { -#endif reclen += strlen(CSTRc(wpt->notes)); } } else { @@ -715,11 +711,7 @@ mps_waypoint_w(gbfile* mps_file, int mps_ver, const Waypoint* wpt, const int isR gbfputc(1, mps_file); gbfputdbl(mps_altitude, mps_file); } -#if NEW_STRINGS if (!wpt->description.isEmpty()) { -#else - if (wpt->description) { -#endif gbfputs(ascii_description, mps_file); } gbfwrite(zbuf, 1, 1, mps_file); /* NULL termination */ diff --git a/gpsbabel/mkshort.cc b/gpsbabel/mkshort.cc index 5d92cfeca..010b32f18 100644 --- a/gpsbabel/mkshort.cc +++ b/gpsbabel/mkshort.cc @@ -585,7 +585,7 @@ mkshort(short_handle h, const QString& istring) * As above, but arg list is a waypoint so we can centralize * the code that considers the alternate sources. */ -String +QString mkshort_from_wpt(short_handle h, const Waypoint* wpt) { /* This probably came from a Groundspeak Pocket Query @@ -594,27 +594,15 @@ mkshort_from_wpt(short_handle h, const Waypoint* wpt) * more stuff than should be in any one field... */ if (wpt->gc_data->diff && wpt->gc_data->terr && -#if NEW_STRINGS !wpt->notes.isEmpty()) { -#else - wpt->notes && wpt->notes[0]) { -#endif return mkshort(h, wpt->notes); } -#if NEW_STRINGS if (!wpt->description.isEmpty()) { -#else - if (wpt->description) { -#endif return mkshort(h, wpt->description); } -#if NEW_STRINGS if (!wpt->notes.isEmpty()) { -#else - if (wpt->notes) { -#endif return mkshort(h, wpt->notes); } diff --git a/gpsbabel/mmo.cc b/gpsbabel/mmo.cc index 5668af700..6e18f672a 100644 --- a/gpsbabel/mmo.cc +++ b/gpsbabel/mmo.cc @@ -1231,7 +1231,7 @@ static void mmo_write_wpt_cb(const Waypoint* wpt) { char* str; - String cx; + QString cx; int objid; time_t time; int icon = 0; diff --git a/gpsbabel/naviguide.cc b/gpsbabel/naviguide.cc index f78b0ef4b..e95cbf03d 100644 --- a/gpsbabel/naviguide.cc +++ b/gpsbabel/naviguide.cc @@ -254,7 +254,7 @@ ng_waypt_rd(const Waypoint* wpt) WPNC.wp_data.North = (int32_t)lat; WPNC.wp_data.East = (int32_t)lon; - String s; + QString s; if (reorder_wp) { sprintf(temp_short_name, "A%03d", current_wp_ix); s = temp_short_name; diff --git a/gpsbabel/netstumbler.cc b/gpsbabel/netstumbler.cc index f80e0d30c..82f809589 100644 --- a/gpsbabel/netstumbler.cc +++ b/gpsbabel/netstumbler.cc @@ -276,11 +276,7 @@ compare(const void* a, const void* b) Waypoint* wpt_a = ((const htable_t*)a)->wpt; Waypoint* wpt_b = ((const htable_t*)b)->wpt; -#if NEW_STRINGS return wpt_a->description.compare(wpt_b->description); -#else - return strcmp(wpt_a->description, wpt_b->description); -#endif } } diff --git a/gpsbabel/nmea.cc b/gpsbabel/nmea.cc index 22d607d1c..4dae1f5e5 100644 --- a/gpsbabel/nmea.cc +++ b/gpsbabel/nmea.cc @@ -1221,7 +1221,7 @@ nmea_wayptpr(const Waypoint* wpt) { char obuf[200]; double lat,lon; - String s; + QString s; int cksum; lat = degrees2ddmm(wpt->latitude); @@ -1243,11 +1243,6 @@ nmea_wayptpr(const Waypoint* wpt) gbfflush(file_out); gb_sleep(sleepus); } -#if NEW_STRINGS -#else - xfree(s); -#endif - } void diff --git a/gpsbabel/raymarine.cc b/gpsbabel/raymarine.cc index f8e875b14..24fd69dc0 100644 --- a/gpsbabel/raymarine.cc +++ b/gpsbabel/raymarine.cc @@ -278,11 +278,7 @@ static char same_points(const Waypoint* A, const Waypoint* B) { return ( /* !!! We are case-sensitive !!! */ -#if NEW_STRINGS (A->shortname == B->shortname) && -#else - (strcmp(A->shortname, B->shortname) == 0) && -#endif (A->latitude == B->latitude) && (A->longitude == B->longitude)); } @@ -334,11 +330,7 @@ qsort_cb(const void* a, const void* b) { const Waypoint* wa = *(Waypoint**)a; const Waypoint* wb = *(Waypoint**)b; -#if NEW_STRINGS return wa->shortname.compare(wb->shortname); -#else - return strcmp(wa->shortname, wb->shortname); -#endif } static void diff --git a/gpsbabel/stmsdf.cc b/gpsbabel/stmsdf.cc index 9e63c0562..c1b34a405 100644 --- a/gpsbabel/stmsdf.cc +++ b/gpsbabel/stmsdf.cc @@ -507,11 +507,7 @@ any_hdr_calc_cb(const route_head* trk) return; } -#if NEW_STRINGS if (rte_name.isEmpty() && !trk->rte_name.isEmpty()) { -#else - if (rte_name.isEmpty() && trk->rte_name) { -#endif rte_name = trk->rte_name; rte_desc = trk->rte_desc; } diff --git a/gpsbabel/stmwpp.cc b/gpsbabel/stmwpp.cc index 602fd232c..4b77abc07 100644 --- a/gpsbabel/stmwpp.cc +++ b/gpsbabel/stmwpp.cc @@ -246,7 +246,7 @@ stmwpp_waypt_cb(const Waypoint* wpt) snprintf(cdate, sizeof(cdate), "%02d/%02d/%04d", tm.tm_mon, tm.tm_mday, tm.tm_year); snprintf(ctime, sizeof(ctime), "%02d:%02d:%02d", tm.tm_hour, tm.tm_min, tm.tm_sec); - String sn; + QString sn; switch (what) { case STM_WAYPT: @@ -257,10 +257,6 @@ stmwpp_waypt_cb(const Waypoint* wpt) sn = mkshort(short_h, wpt->shortname); } gbfprintf(fout, "WP,D,%s,", CSTRc(sn)); -#if NEW_STRINGS -#else - xfree(sn); -#endif break; case STM_TRKPT: diff --git a/gpsbabel/tef_xml.cc b/gpsbabel/tef_xml.cc index 2f15a5b2b..66632b7af 100644 --- a/gpsbabel/tef_xml.cc +++ b/gpsbabel/tef_xml.cc @@ -196,11 +196,7 @@ waypoint_final() if (version < 2) { /* keep the old behaviour */ wpt_tmp->notes = wpt_tmp->description; -#if NEW_STRINGS wpt_tmp->description = QString(); -#else - wpt_tmp->description = NULL; -#endif } wpt_tmp->notes = fix_notes(wpt_tmp->shortname, wpt_tmp->notes); diff --git a/gpsbabel/tmpro.cc b/gpsbabel/tmpro.cc index de21342fe..3e8840125 100644 --- a/gpsbabel/tmpro.cc +++ b/gpsbabel/tmpro.cc @@ -173,17 +173,10 @@ tmpro_waypt_pr(const Waypoint* wpt) { int icon = 1; /* default to "flag" */ int colour = 255; /*default to red */ -#if NEW_STRINGS QString shortname; QString description; if ((wpt->shortname.isEmpty()) || (global_opts.synthesize_shortnames)) { if (!wpt->description.isEmpty()) { -#else - char* shortname = NULL; - char* description = NULL; - if ((! wpt->shortname) || (global_opts.synthesize_shortnames)) { - if (wpt->description) { -#endif if (global_opts.synthesize_shortnames) { shortname = mkshort_from_wpt(mkshort_handle, wpt); } else { @@ -197,13 +190,8 @@ tmpro_waypt_pr(const Waypoint* wpt) shortname = csv_stringclean(wpt->shortname, ",\""); } -#if NEW_STRINGS if (wpt->description.isEmpty()) { if (!shortname.isEmpty()) { -#else - if (! wpt->description) { - if (shortname) { -#endif description = csv_stringclean(shortname, ",\""); } else { description = xstrdup(""); @@ -234,15 +222,6 @@ tmpro_waypt_pr(const Waypoint* wpt) l ? l : "" ); -#if NEW_STRINGS -#else - if (description) { - xfree(description); - } - if (shortname) { - xfree(shortname); - } -#endif if (l) { xfree(l); } diff --git a/gpsbabel/tpg.cc b/gpsbabel/tpg.cc index c41dd9f33..9db086a04 100644 --- a/gpsbabel/tpg.cc +++ b/gpsbabel/tpg.cc @@ -190,13 +190,8 @@ tpg_waypt_pr(const Waypoint* wpt) * and a shortname */ -#if NEW_STRINGS if ((wpt->shortname.isEmpty()) || (global_opts.synthesize_shortnames)) { if (!wpt->description.isEmpty()) { -#else - if ((! wpt->shortname) || (global_opts.synthesize_shortnames)) { - if (wpt->description) { -#endif if (global_opts.synthesize_shortnames) { shortname = mkshort_from_wpt(mkshort_handle, wpt); } else { @@ -209,11 +204,7 @@ tpg_waypt_pr(const Waypoint* wpt) } else { shortname = wpt->shortname; } -#if NEW_STRINGS if (wpt->description.isEmpty()) { -#else - if (! wpt->description) { -#endif if (!shortname.isEmpty()) { description = shortname; } else { diff --git a/gpsbabel/unicsv.cc b/gpsbabel/unicsv.cc index d73ed1150..4a5dc8c21 100644 --- a/gpsbabel/unicsv.cc +++ b/gpsbabel/unicsv.cc @@ -1243,11 +1243,7 @@ unicsv_fatal_outside(const Waypoint* wpt) { gbfprintf(fout, "#####\n"); fatal(MYNAME ": %s (%s) is outside of convertable area of grid \"%s\"!\n", -#if NEW_STRINGS wpt->shortname.isEmpty() ? "Waypoint" : CSTR(wpt->shortname), -#else - wpt->shortname ? CSTRc(wpt->shortname) : "Waypoint", -#endif pretty_deg_format(wpt->latitude, wpt->longitude, 'd', NULL, 0), gt_get_mps_grid_longname(unicsv_grid_idx, MYNAME)); } @@ -1304,20 +1300,11 @@ unicsv_waypt_enum_cb(const Waypoint* wpt) if (!wpt->icon_descr.isNull()) { gb_setbit(&unicsv_outp_flags, fld_symbol); } -#if NEW_STRINGS if (!wpt->description.isEmpty() && shortname != wpt->description) { -#else - if (wpt->description && *wpt->description && shortname != wpt->description) { -#endif gb_setbit(&unicsv_outp_flags, fld_description); } -#if NEW_STRINGS if (!wpt->notes.isEmpty() && shortname != wpt->notes) { if ((wpt->description.isEmpty()) || (wpt->description != wpt->notes)) { -#else - if (wpt->notes && *wpt->notes && shortname != wpt->notes) { - if ((! wpt->description) || (strcmp(wpt->description, wpt->notes) != 0)) { -#endif gb_setbit(&unicsv_outp_flags, fld_notes); } } diff --git a/gpsbabel/vitosmt.cc b/gpsbabel/vitosmt.cc index 3d8582158..041f414a0 100644 --- a/gpsbabel/vitosmt.cc +++ b/gpsbabel/vitosmt.cc @@ -170,12 +170,7 @@ vitosmt_read(void) double usec = fmod(1000000*seconds+0.5,1000000); wpt_tmp->SetCreationTime(mkgmtime(&tmStruct), lround(usec/1000.0)); -#if NEW_STRINGS wpt_tmp->shortname = QString().sprintf("WP%04d", ++serial); -#else - wpt_tmp->shortname = (char*) xcalloc(16,1); - snprintf(wpt_tmp->shortname, 15 , "WP%04d", ++serial); -#endif WAYPT_SET(wpt_tmp, speed, KNOTS_TO_MPS(speed)); /* meters per second */ WAYPT_SET(wpt_tmp, course, course); diff --git a/gpsbabel/waypt.cc b/gpsbabel/waypt.cc index 9425edc5c..c84ebb37d 100644 --- a/gpsbabel/waypt.cc +++ b/gpsbabel/waypt.cc @@ -177,11 +177,7 @@ waypt_disp(const Waypoint* wpt) } printposn(wpt->latitude,1); printposn(wpt->longitude,0); -#if NEW_STRINGS if (!wpt->description.isEmpty()) { -#else - if (wpt->description) { -#endif printf("%s/%s", global_opts.synthesize_shortnames ? qPrintable(mkshort(mkshort_handle, wpt->description)) : @@ -559,15 +555,6 @@ Waypoint::Waypoint() : altitude(unknown_alt), depth(0), proximity(0), -#if !NEW_STRINGS - shortname(NULL), - description(NULL), - notes(NULL), -#endif - // url_link_list_(), - // wpt_flags(), - // icon_descr(), - // creation_time(), route_priority(0), hdop(0), vdop(0), diff --git a/gpsbabel/wfff_xml.cc b/gpsbabel/wfff_xml.cc index 3ea2ce7ca..8d303ff71 100644 --- a/gpsbabel/wfff_xml.cc +++ b/gpsbabel/wfff_xml.cc @@ -54,7 +54,6 @@ arglist_t wfff_xml_args[] = { #define xfreez(p) { if (p) xfree(p); p=0; } #define MYNAME "wfff_xml" -#define MY_CBUF 4096 static xg_callback wfff_s, wfff_e; static xg_callback wfff_wep, wfff_mac, wfff_type; diff --git a/gpsbabel/xmlgeneric.cc b/gpsbabel/xmlgeneric.cc index 92558fe5b..05ea8134b 100644 --- a/gpsbabel/xmlgeneric.cc +++ b/gpsbabel/xmlgeneric.cc @@ -139,11 +139,7 @@ xml_run_parser(QXmlStreamReader& reader, QString& current_tag) // thus we will not process the EndElement case as we will issue a readNext first. // does a caller ever expect to be able to use both a cb_cdata and a // cb_end callback? -#if NEW_STRINGS cb(c, NULL); -#else - cb(CSTRE(c), NULL); -#endif current_tag.chop(reader.qualifiedName().length() + 1); } break; @@ -155,11 +151,7 @@ xml_run_parser(QXmlStreamReader& reader, QString& current_tag) cb = xml_tbl_lookup(current_tag, cb_end); if (cb) { -#if NEW_STRINGS cb(reader.name().toString(), NULL); -#else - cb(CSTRE(reader.name().toString()), NULL); -#endif } current_tag.chop(reader.qualifiedName().length() + 1); break; diff --git a/gpsbabel/xol.cc b/gpsbabel/xol.cc index f75cd0abe..f7880ac8b 100644 --- a/gpsbabel/xol.cc +++ b/gpsbabel/xol.cc @@ -166,11 +166,7 @@ xol_fatal_outside(const Waypoint* wpt) { gbfprintf(fout, "#####\n"); fatal(MYNAME ": %s (%s) is outside of convertable area \"%s\"!\n", -#if NEW_STRINGS wpt->shortname.isEmpty() ? "Waypoint" : CSTRc(wpt->shortname), -#else - wpt->shortname ? CSTRc(wpt->shortname) : "Waypoint", -#endif pretty_deg_format(wpt->latitude, wpt->longitude, 'd', NULL, 0), gt_get_mps_grid_longname(grid_swiss, MYNAME)); } -- 2.30.2